package com.gupao.proxydemo.orderdemo;

import com.gupao.proxydemo.orderdemo.proxy.OrderServiceDynamic;
import sun.misc.ProxyGenerator;

import java.io.FileOutputStream;
import java.lang.reflect.Proxy;
import java.util.Date;

public class OrderServiceTest {
    public static void main(String[] args) throws Throwable {
        IOrderService proxyOrderService = (IOrderService) new OrderServiceDynamic().getInstance(new OrderService());
        Order order = new Order();
        order.setCreateTime(new Date());
        order.setId(123);
        order.setOrderSn("12313131");
        proxyOrderService.createOrder(order);

//        OrderService orderService = new OrderService();
//        orderService.createOrder(order);
//        byte[] bytes = ProxyGenerator.generateProxyClass("$OrderProxy0",new Class[]{IOrderService.class});
//        FileOutputStream fos = new FileOutputStream("/Users/wangenji/Documents/$OrderProxy0.class");
//        fos.write(bytes);
//        fos.close();
    }
}
